package com.sfdcj.se.meta.field;

import java.util.HashMap;

import com.sforce.soap._2006._04.metadata.CustomField;

public class TextType extends FieldType {

	static final String TYPE = "Text";

	public int length = 0;

	public TextType() {
		super();
	}

	public void appendXML() {
		buf.append("<length>" + length + "</length>");
		buf.append("<type>" + TYPE + "</type>");
	}

	@Override
	public String getTypeName() {
		return TYPE;
	}

	@Override
	public Object clone() {
		return new TextType();
	}

	@Override
	public void setAttributes(HashMap<String, String> attributes) {
		length = Integer.valueOf(attributes.get("length")).intValue();
	}

	@Override
	public CustomField toCustomField() {
		CustomField field = new CustomField();
		field.setFullName(objectFullname + "." + fullname);
		field.setLabel(label);
		field.setLength(new Integer(length));
		field.setType(com.sforce.soap._2006._04.metadata.FieldType.Text);
		return field;
	}		
	
}
